package com.sc.design.resposibilitychain;

/**
 * @author sc
 * Created on  2017/12/6
 */
public abstract class Handler {
    public final static int FATHER=1;
    public final static int HUSBAND=2;
    public final static int SON=3;

    private int level = 0;
    private Handler nextHandler;
    public Handler(int _level){
        this.level = _level;
    }

    public void setNextHandler(Handler _nextHandler) {
        this.nextHandler = _nextHandler;
    }

    public final void HandlerMessage(IWomen women){
        if(women.getType() == this.level){
            this.response(women);
        }else{
            if(this.nextHandler!=null){
                this.nextHandler.HandlerMessage(women);
            }else{
                System.out.println("没有人了，不同意处理");
            }
        }
    }

    protected abstract void response(IWomen women);
}
